/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.bis.entity;

import com.jeesite.common.lang.DateUtils;
import org.hibernate.validator.constraints.Length;
import java.util.Date;
import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.common.mybatis.annotation.JoinTable.Type;
import com.fasterxml.jackson.annotation.JsonFormat;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;

/**
 * 签到记录Entity
 * @author Zhangning
 * @version 2019-10-13
 */
@Table(name = "bis_sign_in", alias = "a",
		columns = {
				@Column(name = "id", attrName = "id", label = "id", isPK = true),
				@Column(name = "bis_user_id", attrName = "bisUserId", label = "用户ID"),
				@Column(name = "sign_in_time", attrName = "signInTime", label = "签到时间"),
				@Column(includeEntity = DataEntity.class)
		},
		// 支持联合查询，如左右连接查询，支持设置查询自定义关联表的返回字段列
		joinTable = {
				@JoinTable(type = Type.LEFT_JOIN, entity = BisUser.class, alias = "u",
						on = "u.id = a.bis_user_id",
						columns = {
								@Column(includeEntity = BisUser.class)
						}
				)
		},
		orderBy = "a.update_date DESC"
)
public class BisSignIn extends DataEntity<BisSignIn> {
	
	private static final long serialVersionUID = 1L;
	private String bisUserId;		// 用户ID
	private Date signInTime;		// 签到时间
	private BisUser bisUser;		// 签到时间

	public BisSignIn() {
		this(null);
	}

	public BisSignIn(String id){
		super(id);
	}
	
	@Length(min=0, max=64, message="用户ID长度不能超过 64 个字符")
	public String getBisUserId() {
		return bisUserId;
	}

	public void setBisUserId(String bisUserId) {
		this.bisUserId = bisUserId;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getSignInTime() {
		return signInTime;
	}

	public void setSignInTime(Date signInTime) {
		this.signInTime = signInTime;
	}

	public BisUser getBisUser() {
		return bisUser;
	}

	public void setBisUser(BisUser bisUser) {
		this.bisUser = bisUser;
	}

	public Date getSignInTime_gte(){
		return sqlMap.getWhere().getValue("sign_in_time", QueryType.GTE);
	}

	public void setSignInTime_gte(Date signInTime){
		signInTime = DateUtils.getOfDayFirst(signInTime); // 将日期的时间改为0点0分0秒
		sqlMap.getWhere().and("sign_in_time", QueryType.GTE, signInTime);
	}

	public Date getSignInTime_lte(){
		return sqlMap.getWhere().getValue("sign_in_time", QueryType.LTE);
	}

	public void setSignInTime_lte(Date signInTime){
		signInTime = DateUtils.getOfDayLast(signInTime); // 将日期的时间改为23点59分59秒
		sqlMap.getWhere().and("sign_in_time", QueryType.LTE, signInTime);
	}

}